<?php
/**
* @version $Id: help.php 2005-12-27 09:23:43Z Ryan Demmer $
* @package JCE
* @copyright Copyright (C) 2005 Ryan Demmer. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* JCE is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/
defined( '_VALID_MOS' ) or die( 'Restricted Access.' );

if( !$my->id ) die( 'Restricted Access.' );

$version = "1.1.0";

require_once( dirname(__FILE__) . '/classes/jce.class.php' );
require_once( dirname(__FILE__) . '/classes/jce.utils.class.php' );
$jce = new JCE();

function showHelp() {
	global $mainframe, $jce;
	$params = $jce->getParams();
	$helpurl = strval( $params->get( 'help_url', 'http://www.cellardoor.za.net' ) );
	
	$lang = $jce->getLanguage();	
	include_once( $jce->getLibPath() . '/langs/' . $lang . '.php' );
	
	$plugin = mosGetParam( $_REQUEST, 'plugin', '' );
	$jce->setPlugin( $plugin );
	include_once( $jce->getPluginPath() . '/langs/' .  $jce->getPluginLanguage() . '.php' );
	
	$is_manager = strpos( $plugin, 'manager' );
	$fullhelpurl = $helpurl . '/index2.php?option=com_content&amp;task=findkey&pop=0&lang=' . $lang . '&keyref=';
	?>
	<style type="text/css">
	#helpTree {
		height: 440px;
		width: 95%;
		overflow: auto;
	}
	#helpFrame {
		height: 440px;
		width: 95%;
		padding: 0px 5px 0px 10px;
		background: #FFFFFF;
	}
	#handle {
		background-color: #ddd;
		border: 1px outset #999999;
		width: 1px;
		height: 440px;
		cursor: w-resize;
		display: inline-table;
		float: left;
	}
	</style>
	<fieldset>
	<legend><?php echo $pl['title'].' '.$cl['help'];?></legend>
		<table class="properties" cellpadding="0" cellspacing="0">
			<tr>
				<td id="helpTreeCell" style="width:180px; vertical-align:top" nowrap="nowrap"><div id="helpTree"></div></td>
				<td id="handle">&nbsp;</td>
				<script type="text/javascript">
					var lib_url = "<?php echo $jce->getLibUrl();?>";
					d = new dTree('d');
					d.config.target = "helpFrame";
					d.icon.root = lib_url + '/images/help.gif';
					d.icon.folder = lib_url + '/images/book.gif';
					d.icon.folderOpen = lib_url + '/images/book_open.gif';
					d.icon.node = lib_url + '/images/page.gif';
					d.add(0,-1,'<?php echo $cl["index"];?>');					
					<?php 
					$x = 2;
					if( $is_manager ){?>
						d.add(1,0,'<?php echo $cl["common"];?>');
					<?php
						foreach( $ch as $k=>$v ) {
							$url = $fullhelpurl . urlencode( 'manager.' . $k );
						?>
							d.add(<?php echo $x;?>, 1, '<?php echo $v;?>', '<?php echo $url;?>', '<?php echo $v;?>', 'helpFrame');
						<?php 	
							$x++;
						}
					}
					$i = $x;
					$x++;
					?>
					d.add(<?php echo $i;?>,0,'<?php echo $cl["plugin_specific"];?>','');
					<?php 
						foreach ($ph as $k=>$v) {
							$url = $fullhelpurl . urlencode( $plugin . '.' . $k );
					?>
							d.add(<?php echo $x;?>, <?php echo $i;?>, '<?php echo $v;?>', '<?php echo $url;?>', '<?php echo $v;?>', 'helpFrame');
					<?php 	
							$x++;
						}?>	
					document.getElementById('helpTree').innerHTML = d;
				</script>
				<td><iframe name="helpFrame" id="helpFrame" src="<?php echo $fullhelpurl . urlencode( $plugin . '.about' );?>" frameborder="0" /></iframe></td>
			</tr>
		</table>
	</fieldset>
	<br />
	<div style="float:right"><input type="button" class="button" id="cancel" value="<?php echo $cl['cancel'];?>" onClick="window.close();" /></div>
	<?php
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php echo $pl['title'].' '.$cl['help'];?></title>
	<?php echo $jce->printLibJs( 'mootools' );?>
	<?php echo $jce->printLibJs( 'dtree' );?>
	<link href="<?php echo $jce->getTinyUrl();?>/themes/advanced/css/editor_popup.css" rel="stylesheet" type="text/css" />
	<?php echo $jce->printLibCss( 'common' );?>
	<?php echo $jce->printLibCss( 'dtree' );?>
	<script type="text/javascript">
		Element.extend({	
			makeResizable: function(options){
				return new Drag.Base(this, 'width', '', options);
			}
		});
		function init(){
			$('helpTreeCell').makeResizable({handle: $('handle'), xMin: '100', xMax: '400'});
		}
	</script>
</head>
<body onLoad="init();">
	<form>
		<?php echo showHelp();?>
	</form>
</body>
</html>
